package com.example.demo.customer;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;

@Entity
@Table
public class Customer {

        @Id
        private long id;

        @NotBlank(message = "name 不能为空")
        private String name;

    public Customer() {

    }

    @Override
    public String toString() {
        return "Customer{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", email='" + email + '\'' +
                ", password='" + password + '\'' +
                '}';
    }

    public String getEmail() {
        return email;
    }

    @NotBlank(message = "email 不能为空")
    @Email
    private String email;

    @JsonIgnore
    public String getPassword() {
        return password;
    }

    @NotBlank
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    private String password;


   /* public long getCustomerId(){
            return id;
        }*/

        public String getName() {
            return name;
        }
        @JsonProperty("CustomerId")
        public long getId() {
            return id;
        }

        public Customer(long id, String name, String email, String password) {
            this.id = id;
            this.name = name;
            this.email = email;
            this.password = password;
        }
    }
